<style>
	@import "../../../common/css/adminHome.css";
</style>
<template>
	<view>
		<view class="admin_common_page">
			<view class="top_fix" style="height: 280rpx;">
				<view class="search_info">
				</view>
				<view class="">
					<view class="">
						<picker mode="selector" :range="list" :range-key="'endTime'" @change="change" :value="index"
							style="color:#fff;margin-left:20rpx;">
							<view class="">
								点击选择日期:
							</view>
							<view class="" style="display: flex;flex-direction:row;">
								<view style="border: 3px solid #ffff;width: 260rpx;margin-bottom: 20rpx;">
									{{list[index].endTime}}
								</view>
								<!-- 	<button type="default" size="mini" :id="list[index].id" @click.stop="caigou"
									style="height: 60rpx;">采购汇总</button> -->
								<button type="default" size="mini" :id="list[index].id" @click.stop="fenjian"
									style="height: 60rpx;">分拣查看</button>
							</view>
						</picker>
					</view>
				</view>
				<view class="" v-if="lists">
					<uni-card @click="clickCard(id)" :title="lists.agentShopName" mode="basic" :is-shadow="true"
						:extra='"状态:"+`${lists.status == 0 ? "未分拣" : lists.status == 1 ?"配送中":"已到店" }`' note="更多信息 >>">
						<view class="">
							所属社区:{{lists.cscName}}
						</view>
						<view class="">
							创建时间:{{lists.createTime}}
						</view>
					</uni-card>
				</view>
				<view class="" style="padding-bottom: 100rpx;">
				</view>
			</view>
		</view>
		<tabBarAdmin :pagePath="'/pages/admin/shangjia/shangjia'"></tabBarAdmin>
	</view>


</template>

<script>
	export default {
		data() {
			return {
				agentShopIds: null,
				id: null, //活动ID
				// fenjian:true,
				list: [], //活动列表
				index: 0,
				lists: null, //商铺列表内容

			}
		},
		// mounted(){
			
		// 	uni.getStorage({
		// 		key: "shopId",
		// 		success(e) {
		// 			console.log(67,e.data,this)
		// 			this.agentShopIds = e.data
		// 		}
		// 	})
		// },
		// onLoad() {
		// 	uni.getStorage({
		// 		key: "shopId",
		// 		success(e) {
		// 			console.log(e.data)
		// 		}
		// 	})
		// },
		methods: {
			//拨打电话
			phone(e) {
				console.log(e.currentTarget.id)
				uni.makePhoneCall({
					phoneNumber: e.currentTarget.id //仅为示例
				})
			},

			//点击卡片
			clickCard(e) {

				console.log(e)
				uni.navigateTo({
					url: '../../admin/shangjiafenjian/shangjiafenjian?agentShopId=' + this.agentShopIds +
						"&activityId=" + this.id,
					// events:{
					// 	data2:(res)=>{
					// 		console.log(res,"店铺Id")
					// 		//更新自提点
					// 		for (var i=0;i<that.shops.length;i++)
					// 		{ 
					// 		   if(that.shops[i].shopId == res){
					// 			   that.shop.address=that.shops[i].address
					// 			    that.shop.distance=that.shops[i].distance
					// 			   that.shop.phone=that.shops[i].phone				 
					// 			   that.shop.shopName= that.shops[i].shopName
					// 			   that.shop.shopPic=that.shops[i].shopPic
					// 			   that.shop.shopId = that.shops[i].shopId
					// 		   }
					// 		}
					// 	}
					// }
				});
			},
			change(e) {
				console.log(e)
				this.index = e.detail.value
			},
			caigou(e) {


				console.log("采购汇总", e.currentTarget.id)
				let postData = {
					activityId: e.currentTarget.id
				}

				// console.log(106,postData)
				this.$api.caigou.purchase(postData)
					.then(res => {
						if (res.code == 200) {
							// this.scsList = res.data
							console.log("采购汇总", res.data)
							this.lists = res.rows
							// this.fenjian = false



						} else {
							this.$commonJs.showToast.showNoneToast(res.err)
						}
					})
					.catch(err => {
						this.$commonJs.showToast.showNoneToast(err)
					})
			},
			fenjian(e) {
				console.log("分拣汇总", e.currentTarget.id)
				let that = this
				uni.getStorage({
					key: "shopId",
					success(res) {
						console.log(res.data)
						that.agentShopIds = res.data
						let postData = {
							activityId: e.currentTarget.id,
							agentShopId: res.data
						}
						that.id = e.currentTarget.id
						// console.log(106,postData)
						that.$api.caigou.purchaseAgentShop_info(postData)
							.then(res => {
								if (res.code == 200) {
									that.lists = res.data
									console.log("分拣汇总", res.rows)
									// this.fenjian = true
						
						
						
								} else {
									that.$commonJs.showToast.showNoneToast(res.err)
								}
							})
							.catch(err => {
								that.$commonJs.showToast.showNoneToast(err)
							})
					}
				})
				console.log("153", that.agentShopIds)
				
			},
		},
		mounted() {
			
			// let postData = {endTime:this.single}
			// console.log(106,postData)
			this.$api.caigou.activity()
				.then(res => {
					if (res.code == 200) {
						// this.scsList = res.data
						console.log(res.data)
						this.list = res.rows



					} else {
						this.$commonJs.showToast.showNoneToast(res.err)
					}
				})
				.catch(err => {
					this.$commonJs.showToast.showNoneToast(err)
				})
		}
	}
</script>

<style>

</style>
